#include "stm32f10x.h"                  // Device header
#include "Motor.h"
#include "Delay.h"
#include "Key.h"
#include "OLED.h"

uint8_t KeyNum;
int8_t Speed;

int main()
{
	Motor_Init();
	OLED_Init();
	Key_Init(GPIO_Pin_0 | GPIO_Pin_10);
	
	OLED_ShowString(1, 1, "Speed:");
	while(1)
	{
		KeyNum = Key();
		if(KeyNum == 1)
		{
			Speed += 20;
			if(Speed > 100)
				Speed = 0;
			Motor_SetSpeed(Speed);
			OLED_ShowSignedNum(1, 7, Speed, 3);
		}
		else if(KeyNum == 11)
		{
			Speed -= 20;
			if(Speed < -100)
				Speed = 0;
			Motor_SetSpeed(Speed);
			OLED_ShowSignedNum(1, 7, Speed, 3);
		}
	}
}
